package com.atguigu.gulimall.seckill.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
public class MyRedisConfig {
    /**
     * 所有对 redisson 的使用都是通过 RedissonClient 对象
     */
    @Bean(destroyMethod = "shutdown")    //销毁方法，如果服务停止了会调用它
    public RedissonClient redisson() throws IOException {
        //1、创建配置
        Config config = new Config();
        config.useSingleServer().setAddress("redis://192.168.56.10:6379");
        //2、根据 Config 创建出 RedissonClient 示例
        RedissonClient redisson = Redisson.create(config);
        return redisson;
    }}

